package com.manda.smart.hub.common.exception;

import cn.hutool.core.text.CharSequenceUtil;
import lombok.Getter;

/**
 * @author hongda.li
 */
@Getter
public class StandardException extends RuntimeException {

    private final Object[] arguments;

    private final Throwable throwable;

    public StandardException() {
        super();
        this.arguments = null;
        this.throwable = null;
    }

    public StandardException(String message) {
        super(message);
        this.arguments = null;
        this.throwable = null;
    }

    public StandardException(Throwable throwable) {
        super(throwable);
        this.throwable = throwable;
        this.arguments = null;
    }

    public StandardException(String message, Object... arguments) {
        super(CharSequenceUtil.format(message, arguments));
        this.arguments = arguments;
        this.throwable = null;
    }

    public StandardException(String message, Throwable throwable) {
        super(message, throwable);
        this.throwable = throwable;
        this.arguments = null;
    }

    public StandardException(String message, Throwable throwable, Object... arguments) {
        super(CharSequenceUtil.format(message, arguments), throwable);
        this.arguments = arguments;
        this.throwable = throwable;
    }
}
